import java.util.*;

/**
 * @author gao
 * @date 2025/11/16 18:28
 */

public class Solution {
    public int[] intersection(int[] nums1, int[] nums2) {
        Set<Integer> set = new HashSet<>();
        for (int i : nums1) {
            set.add(i);
        }

        List<Integer> list = new ArrayList<>();

        for (int i : nums2) {
            if (set.contains(i)) {
                list.add(i);
                set.remove(i);
            }
        }

        int[] ret = new int[list.size()];
        for (int i = 0; i < ret.length; i++) {
            ret[i] = list.get(i);
        }

        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n1 = in.nextInt();
            int[] nums1 = new int[n1];
            for (int i = 0; i < n1; i++) {
                nums1[i] = in.nextInt();
            }

            int n2 = in.nextInt();
            int[] nums2 = new int[n2];
            for (int i = 0; i < n2; i++) {
                nums2[i] = in.nextInt();
            }

            Solution solution = new Solution();
            System.out.println(Arrays.toString(solution.intersection(nums1, nums2)));
        }
    }
}